package com.bi.autotest.cases;

import com.auto.base.Assertion;
import com.auto.base.InitAppium;
import com.bi.autotest.operations.CScanBOperation;
import com.bi.autotest.operations.MyLoginOperation;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.net.MalformedURLException;

/**
 * Created by yidian on 2018/4/23.
 */
public class CScanB extends InitAppium {

    private MyLoginOperation myLoginOperate;
    private CScanBOperation cScanBOperation;

    @BeforeClass
    public void initDriver(){
        try {
            setUp();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        Assert.assertNotNull(driver);
        myLoginOperate = new MyLoginOperation(driver);
        cScanBOperation=new CScanBOperation(driver);

        //直接用缓存登录上去
        login_HasCache();
    }

    public void login_HasCache(){
        boolean isSuccess=myLoginOperate.LoginPreNew();
        print("直接用缓存登陆的情况 开通了渠道");
    }

    //不设置金额的情况
    @Test(priority = 0)
    public void payZero(){
        cScanBOperation.longPressQRCodeImg();
        boolean isHasVipCardPay=cScanBOperation.payZero();
        Assertion.verifyEquals(isHasVipCardPay,false,"不设置金额 输入0.00元直接点击确认支付的情况");
    }

    @Test(priority = 1)
    public void payCorrectMoneyLeague(){
        cScanBOperation.longPressQRCodeImg();
        boolean isPaySuccess=cScanBOperation.payCorrectMoneyLeague();
        Assertion.verifyEquals(isPaySuccess,true,"不设置金额 输入0.01元直接使用联盟卡点击确认支付的情况");
    }
    @Test(priority = 2)
    public void payCorrectMoneyVipMark(){
        cScanBOperation.longPressQRCodeImg();
        boolean isPaySuccess=cScanBOperation.payCorrectMoneyVipMark();
        Assertion.verifyEquals(isPaySuccess,true,"不设置金额 输入0.02元 切换会员卡添加备注支付的情况");
    }

    @Test(priority = 3)
    public void payCorrectMoneyMarkLeagueWX(){
        cScanBOperation.longPressQRCodeImg();
        boolean isPaySuccess=cScanBOperation.payCorrectMoneyMarkLeagueWX();
        Assertion.verifyEquals(isPaySuccess,true,"不设置金额 输入1000元 切换联盟卡余额不足自动调用微信支付的情况");
    }

    @Test(priority = 4)
    public void payCorrectMoneyMarkVipWX(){
        cScanBOperation.longPressQRCodeImg();
        boolean isPaySuccess=cScanBOperation.payCorrectMoneyMarkVipWX();
        Assertion.verifyEquals(isPaySuccess,true,"不设置金额 输入1000元 会员卡余额不足自动调用微信支付的情况");
    }

    //设置金额的情况**********************************************
    @Test(priority = 5)
    public void payZeroSet(){
        boolean isExistInpuEffectText=cScanBOperation.payZeroSet();
        Assertion.verifyEquals(isExistInpuEffectText,true,"设置金额 输入0.00元直接点击确认的情况");
    }
    //设置金额的情况
    @Test(priority = 6)
    public void payCorrectSet(){
        boolean isExistClearText=cScanBOperation.payCorrectSet();
        Assertion.verifyEquals(isExistClearText,true,"设置金额 输入0.01元的情况");
    }

    //在设置为0.01的情况下 联盟卡付款
    @Test(priority = 7)
    public void payCorrectSetLeague(){
        cScanBOperation.longPressQRCodeImg();
        boolean isExistClearText=cScanBOperation.payCorrectSetLeague();
        Assertion.verifyEquals(isExistClearText,true,"设置为0.01的情况下 联盟卡付款的情况");
    }

    //在设置为0.01的情况下 切换为会员卡付款
    @Test(priority = 8)
    public void payCorrectSetVip(){
        cScanBOperation.longPressQRCodeImg();
        boolean isExistClearText=cScanBOperation.payCorrectSetVip();
        Assertion.verifyEquals(isExistClearText,true,"设置为0.01的情况下 会员卡付款的情况");
    }

    //在设置为1000的情况下 联盟卡付款 余额不足调用微信的情况
    @Test(priority = 9)
    public void payCorrectSetLeagueWX(){
        cScanBOperation.setLargeAmount();
        cScanBOperation.longPressQRCodeImg();
        boolean isSuccess=cScanBOperation.payCorrectSetLeagueWX();
        Assertion.verifyEquals(isSuccess,true,"设置为1000的情况下 联盟卡付款 余额不足调用微信的情况");
    }

    //在设置为1000的情况下  切换为会员卡 余额不足调用微信的情况
    @Test(priority = 10)
    public void payCorrectSetVipWX(){
        cScanBOperation.longPressQRCodeImg();
        boolean isSuccess=cScanBOperation.payCorrectSetVipWX();
        Assertion.verifyEquals(isSuccess,true,"设置为1000的情况下  切换为会员卡 余额不足调用微信的情况");
    }

    //直接添加商品的情况
    @Test(priority = 11)
    public void payCorrectSetAddGoods(){
        boolean isSuccess=cScanBOperation.payCorrectSetAddGoods();
        Assertion.verifyEquals(isSuccess,true,"直接添加商品的情况");
    }

    //测试重复设置金额 会不会出现清除失败的情况
    @Test(priority = 12)
    public void setMoneyManyTimes(){
        boolean isSuccess1=cScanBOperation.setMoneyManyTimes();
        boolean isSuccess2=cScanBOperation.setMoneyManyTimes();
        boolean isSuccess3=cScanBOperation.setMoneyManyTimes();
        boolean flag=isSuccess1 && isSuccess2 && isSuccess3;

        Assertion.verifyEquals(flag,true,"测试重复设置金额 会不会出现清除失败的情况");
    }

    //测试重复设置金额中添加商品 会不会出现清除失败的情况
    @Test(priority = 13)
    public void setAddGoodsManyTimes(){
        boolean isSuccess1=cScanBOperation.setAddGoodsManyTimes();
        boolean isSuccess2=cScanBOperation.setAddGoodsManyTimes();
        boolean isSuccess3=cScanBOperation.setAddGoodsManyTimes();
        boolean flag=isSuccess1 && isSuccess2 && isSuccess3;
        Assertion.verifyEquals(flag,true,"测试重复设置金额中添加商品 会不会出现清除失败的情况");
    }

    //切换门店为超市  会员卡余额不够 用返利支付的情况
    @Test(priority = 14)
    public void changeStoreFanLiPay(){
        boolean isSuccess=cScanBOperation.changeStoreFanLiPay();
        Assertion.verifyEquals(isSuccess,true,"切换门店为超市  会员卡余额不够 用返利支付的情况");
    }

    //切换门店为qwer  未开通收款渠道的情况
    @Test(priority = 15)
    public void changeFlavor(){
        boolean isSuccess=cScanBOperation.changeFlavor();
        Assertion.verifyEquals(isSuccess,true,"切换门店为qwer  未开通收款渠道的情况");
    }



}
